<?php


class InspectionScreen extends CI_Controller
{
    private $proLineTable;

    public function __construct()
    {
        parent::__construct();
        $this->proLineTable = "gzrb_productline";
    }

    public function index(){
        $this->load->model();
    }

    public function showScreen(){
        $get = $this->input->get();
        $where = array();
        $productLine = "";
        if(isset($get['productLine']) and strlen($get['productLine']) > 0){
            $productLine = $get['productLine'];
            $where['productLine'] = $productLine;
        }
        $yipei = array(
            "ldtyt"            => $this->getTodayLogCount("gzrb_yipei_ldtyt", $where),
            "czjzjlb"          => $this->getTodayLogCount("gzrb_yipei_czjzjlb", $where),
            "gjdjb"            => $this->getTodayLogCount("gzrb_yipei_gjdjb", $where),
            "hjctjlb"          => $this->getTodayLogCount("gzrb_yipei_hjctjlb", $where),
            "sbejdjb"          => $this->getTodayLogCount("gzrb_yipei_sbejdjb", $where),
            "sbyjdjb"          => $this->getTodayLogCount("gzrb_yipei_sbyjdjb", $where),
            "sbyjdjb2f"          => $this->getTodayLogCount("gzrb_yipei_sbyjdjb2f", $where),
            "ycctqljlb"          => $this->getTodayLogCount("gzrb_yipei_ycctqljlb", $where),
            "hljwsdtyt"          => $this->getTodayLogCount("gzrb_yipei_hljwsdtyt", $where),
            "tljwsdtyt"          => $this->getTodayLogCount("gzrb_yipei_tljwsdtyt", $where),
        );
        $yishao = array(
            "sbyjdjb"          => $this->getTodayLogCount("gzrb_yishao_sbyjdjb", $where),
            "sbejdjb"          => $this->getTodayLogCount("gzrb_yishao_sbejdjb", $where),
            "hjctjlb"          => $this->getTodayLogCount("gzrb_yishao_hjctjlb", $where),
            "sjzbljcb"          => $this->getTodayLogCount("gzrb_yishao_sjzbljcb", $where),
            "ylyhljcjlb"          => $this->getTodayLogCount("gzrb_yishao_ylyhljcjlb", $where),
            "ylpqkqljlb"          => $this->getTodayLogCount("gzrb_yishao_ylpqkqljlb", $where),
        );
        $posui = array(
            "sbyjdjbdanj1f"          => $this->getTodayLogCount("gzrb_posui_sbyjdjbdanj1f", $where),
            "sbyjdjbdanj4f"          => $this->getTodayLogCount("gzrb_posui_sbyjdjbdanj4f", $where),
            "sbejdjb"                => $this->getTodayLogCount("gzrb_posui_sbejdjb", $where),
            "hjctjlb"                => $this->getTodayLogCount("gzrb_posui_hjctjlb", $where),
            "ycctqljlb"              => $this->getTodayLogCount("gzrb_posui_ycctqljlb", $where),
            "yskqgllxqljlb"          => $this->getTodayLogCount("gzrb_posui_yskqgllxqljlb", $where),
            "qlmfsgcczjlb"           => $this->getTodayLogCount("gzrb_posui_qlmfsgcczjlb", $where),
        );
//        var_dump($yipei);exit;
        $info['site_template'] = 'rbReport';
        $info['site_templateurl'] = base_url('/html').'/'.$info['site_template'];
        $lineData = $this->getLine();
        $res = array(
            'config'  => $info,
            'yipei'   => $yipei,
            'yishao'  => $yishao,
            'posui'   => $posui,
            'lineData'=> $lineData,
            'productLine' => $productLine,
        );
        $this->load->view("rbReport/showScreen",$res);
    }

    public function getTodayLogCount($tablename, $where = array()){
        $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
        $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
        $where["createTIme > "] = $beginToday;
        $where['createTime <='] = $endToday;
//        $data = $this->Data_model->get_data(array("createTIme > " => $beginToday,"createTime <=" => $endToday),"","",0,0,$tablename);
        $data = $this->Data_model->get_data($where,"","",0,0,$tablename);
        return count($data);
    }

    /*
     * 获取所有的产线信息
     */
    function getLine(){
        $data = $this->Data_model->get_data(array("status" => 1),"","",0,0,$this->proLineTable);
        return $data;
    }
}